package com.woniu.controller.backpage;


import com.woniu.entity.Orders;
import com.woniu.service.backpage.IOrdersService;
import com.woniu.util.RequestParams;
import com.woniu.util.ResData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * 订单表controller层
 * @author 任楷锐
 * @data 2023/3/6 10:52
 */
@RestController
@RequestMapping("/orders")
public class OrdersController {
    @Autowired
    private IOrdersService ordersService;

    /*查询所有订单*/
    @RequestMapping("/getAllOrders")
    public ResData<?> getAllOrder(@RequestBody RequestParams<Orders> requestParams){
        ResData<?> allOrders = ordersService.getAllOrders(requestParams);
        return allOrders;
    }

    /*数据看板——查看当前月份订单数*/
    @RequestMapping("/queryCount")
        public ResData<?> queryMoonOrdersCount(@RequestBody Orders orders){
        return ordersService.queryMoonOrdersCount(orders.getStartTime(),orders.getEndTime());
    }

    /*数据看板——查看当前月份成交金额*/
    @RequestMapping("/queryMoonOrdersAmount")
    public ResData<?> queryMoonOrdersAmount(@RequestBody Orders orders){
        return ordersService.queryMoonOrdersAmount(orders.getStartTime(),orders.getEndTime());
    }

    /*数据看板——根据月份查看订单数量*/
    @RequestMapping("/queryOrdersCountByCreateTime")
    public ResData<?> queryOrdersCountByCreateTime(){
        return ordersService.queryOrdersCountByCreateTime();
    }

    @RequestMapping("/queryOrdersAmountByCreateTime")
    public ResData<?> queryOrdersAmountByCreateTime(){
        return ordersService.queryAmountByCreateTime();
    }
}
